#include <shell/cmd.h>
#include <shell/shell.h>
#include <system/kernel.h>
#include <system/mod.h>



/*
 * Visualizza una stringa
 */
void cmd_echo()
{
	int x;
	for(x = 1; x < argc; x++)
	{
		puts(argv[x]);
		if(x+1 < argc) putchar(' ');
	}
	putchar('\n');
}


/*
 * Visualizza la lista dei commandi
 */
void cmd_help()
{
	printf("spiderpig shell, compiled on %s at %s\n", __DATE__, __TIME__);
	printf("help          - show this help\n");
	printf("shutdown      - shutdown the computer\n");
	printf("echo [s]      - print a string\n");
	printf("mod [args]    - all about modules\n");
	printf("clear         - clear the screen\n");
	printf("splogo        - show system logo\n");
	printf("spinfo        - show info about spiderpig\n");
	printf("tower         - show a tower\n");
	printf("exit          - exit the shell\n");
}


/*
 * Mostra info sulla relase di spiderpig
 */
void cmd_spinfo()
{
	video_puts("Spiderpig " SP_VERSION " compiled on " __DATE__ " at " __TIME__ "\n");
}

/*
 * Visualizza il logo
 */
void cmd_splogo()
{
	spiderpig_logo();	
}


/*
 * Spegne la macchina
 */
void cmd_shutdown()
{
	asm("cli");
	asm("hlt");
}


/*
 * Pulisce lo schermo
 */
void cmd_clear()
{
	video_clear();
}


/*
 * Display an idiot tower
 */
void cmd_tower()
{
	int floor = 10;
	int i,j,k;
	
	for (k=1; k<=floor; k++)
	{
		for (j=0; j<=(floor-k); j++)
			printf (" ");
		for (i=1; i<=(k*2)-1; i++)
			printf ("*");

		printf ("\n");
	}
}
